import sys

fileName = sys.argv[1]
filesNumber = int(sys.argv[2])
f = open(fileName,'w')
f.write('#EXTM3U\n')
for i in range(1,filesNumber+1):
    fi = open(fileName.split('.')[0]+str(i)+'.m3u','r')
    for line in fi.readlines():
        if "#EXTM3U" in line:
            pass
        else:
            f.write(line)
    fi.close()
f.close()